/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.manager.search;

import br.com.foxline.clinicplus.entity.Appraisal;
import br.com.foxline.clinicplus.entity.Doctor;
import br.com.foxline.clinicplus.enums.SituationAppraisal;
import br.com.foxline.clinicplus.service.AppraisalService;
import br.com.foxline.clinicplus.service.DoctorService;
import br.com.foxline.clinicplus.service.TemplateAppraisalService;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerSearchAppraisal implements Serializable {

    @EJB
    TemplateAppraisalService templateAppraisalService;
    @EJB
    AppraisalService appraisalService;
    @EJB
    DoctorService doctorService;
    private List<Appraisal> searchAppraisal;
    private List<Appraisal> appraisalPendentes;
    private List<Appraisal> appraisalEntregar;
    private List<Appraisal> appraisalFinalizados;
    private SituationAppraisal situationAppraisal;
    
    private Long codAtendimento;
    private Long codLaudo;
    private String nomePaciente;
    private Date data;
    private Doctor doctor;

    @PostConstruct
    public void init() {
        appraisalPendentes = appraisalService.appraisalSituationAppraisal(SituationAppraisal.WAITING);
        appraisalEntregar = appraisalService.appraisalSituationAppraisal(SituationAppraisal.PRODUCTION);
        appraisalFinalizados = appraisalService.appraisalSituationAppraisal(SituationAppraisal.FINISHED);
        searchAppraisal = new ArrayList<Appraisal>();
    }
    
    public List<SelectItem> selectSituationAppraisal() {
        List<SelectItem> paymentTypes = new ArrayList<SelectItem>();
        for (SituationAppraisal ms : SituationAppraisal.values()) {
            paymentTypes.add(new SelectItem(ms, ms.getDesc()));
        }
        return paymentTypes;
    }

    public SituationAppraisal getSituationAppraisal() {
        return situationAppraisal;
    }

    public void setSituationAppraisal(SituationAppraisal situationAppraisal) {
        this.situationAppraisal = situationAppraisal;
    }

    
    public List<Appraisal> getSearchAppraisal() {
        return searchAppraisal;
    }

    public void setSearchAppraisal(List<Appraisal> searchAppraisal) {
        this.searchAppraisal = searchAppraisal;
    }
    
    public Long getCodAtendimento() {
        return codAtendimento;
    }

    public void setCodAtendimento(Long codAtendimento) {
        this.codAtendimento = codAtendimento;
    }

    public Long getCodLaudo() {
        return codLaudo;
    }

    public void setCodLaudo(Long codLaudo) {
        this.codLaudo = codLaudo;
    }

    public String getNomePaciente() {
        return nomePaciente;
    }

    public void setNomePaciente(String nomePaciente) {
        this.nomePaciente = nomePaciente;
    }
    
    public List<Appraisal> getAppraisalEntregar() {
        return appraisalEntregar;
    }

    public void setAppraisalEntregar(List<Appraisal> appraisalEntregar) {
        this.appraisalEntregar = appraisalEntregar;
    }

    public List<Appraisal> getAppraisalFinalizados() {
        return appraisalFinalizados;
    }

    public void setAppraisalFinalizados(List<Appraisal> appraisalFinalizados) {
        this.appraisalFinalizados = appraisalFinalizados;
    }

    public List<Appraisal> getAppraisalPendentes() {
        return appraisalPendentes;
    }

    public void setAppraisalPendentes(List<Appraisal> appraisalPendentes) {
        this.appraisalPendentes = appraisalPendentes;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Doctor getDoctor() {
        return doctor;
    }

    public void setDoctor(Doctor doctor) {
        this.doctor = doctor;
    }
    
    public void search(){
        searchAppraisal = appraisalService.searchAppraisal(codLaudo, codAtendimento, nomePaciente, situationAppraisal, data, doctor);
    }
    
}
